package cn.tedu.smartos.family_user.mapper;

import cn.tedu.smartos.family_user.pojo.entity.ElderlyInfo;
import cn.tedu.smartos.family_user.pojo.entity.FamilyElderlyRelation;
import cn.tedu.smartos.baseuser.pojo.entity.User;
import cn.tedu.smartos.family_user.pojo.vo.BoundElderlyVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Mapper
public interface ElderlyBindMapper {
    //通过userId查询用户信息
    User selectUserById(Long userId);
    //通过手机号查询用户信息
    User selectUserByPhone(String phone);
    //添加用户
    int insertUser(User user);
    //添加老人信息
    int insertElderlyInfo(ElderlyInfo elderlyInfo);
    //添加关系
    int insertRelation(FamilyElderlyRelation relation);
    //判断关系是否存在
    int relationExists(@Param("familyUserId") Long familyUserId,
                       @Param("elderlyUserId") Long elderlyUserId);
    //通过老人id查询关系
    List<Long> selectFamilyUserIdsByElderlyId(@Param("elderlyUserId") Long elderlyUserId);
    //通过关系查询老人信息
    List<BoundElderlyVO> selectBoundElderlyByFamilyUserId(Long familyUserId);
    //删除关系
    int deleteRelation(@Param("familyUserId") Long familyUserId,
                       @Param("elderlyUserId") Long elderlyUserId);
    //通过关系查询
    List<BoundElderlyVO> selectBoundElderlyByCondition(@Param("familyUserId") Long familyUserId,
                                                       @Param("relationType") String relationType,
                                                       @Param("realName") String realName);
}
